#!/usr/bin/env php
<?php

function array_mshift($array, $iterate) 
{ 
    if(!is_array($array) && is_int($iterate)) 
        return false; 

    while(($iterate--)!=false) 
        array_shift($array); 
    return $array; 
} 


$route = shell_exec('route -n');
$route = preg_replace("/\s{2,}/", ' ', $route);
$route = explode(chr(0x0A), $route);
$route = array_mshift($route, 2);
array_pop($route);

foreach($route as $idx => $r)
{
  $info = explode(chr(32), $r);
  echo "dest: $info[0]\t\tgate: $info[1]\n";
}
//var_dump($route);
?>
